{extend name="$base" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/defau.css">
<style>
.table-input{
	height:12px !important;
	line-height:12px !important;
	width:60px;
	margin-bottom:0px !important;
}
</style>
{/block}
{block name="main"}
<!-- <div class="set-style">
	<dl>
		<dt>是否开启全球分红:</dt>
		<dd>			
					{if condition="$shop_config_info.is_global_enable eq 1 "} 
					<input id="is_global_enable" class="checkbox" type="checkbox" checked="checked" />					
					{else /}
					<input id="is_global_enable" class="checkbox" type="checkbox" />
					{/if}
					<span class="help-inline" id="is_menuPrompt" style="display: none;"></span>
		</dd>
	</dl>	
</div> -->
<table class="mytable">
	<tr>
		<th align="left">
			{if condition="$shop_config_info.is_global_enable eq 1 "} 
				<a id="is_global_enable"class="btn-common-white" href="javascript:openGlobalEnable(0)" >关闭全球分红(开启中)</a>
			{else /}
				<a id="is_global_enable"class="btn-common" href="javascript:openGlobalEnable(1)" >开启全球分红(关闭中)</a>
			{/if}
	
		</th>
	</tr>
</table>
<div class="mod-table">
	<div class="mod-table-head">
		<div class="con style0list">
			<table class="table-class">
				<colgroup>
					<col style="width: 10%;">
					<col style="width: 15%;">
					<col style="width: 15%;">
					<col style="width: 15%;">
				</colgroup>
				<thead>
					<tr>						
						<th>等级名称</th>
						<th>全球分红分值</th>
						<th>全球分红权重</th>
						<th>创建时间</th>
					</tr>
				</thead>
				<colgroup>
					<col style="width: 10%;">
					<col style="width: 15%;">
					<col style="width: 15%;">
					<col style="width: 15%;">
				</colgroup>
				<tbody  id="partner_global">
				{foreach name="partner_level_list" item="partner_level_info" }
				    <tr align="center" data-level_id={$partner_level_info.level_id}>
						<td>{$partner_level_info.level_name}</td>
						<td><input  class="input-common middle" type="text" value="{$partner_level_info.global_value}" /></td>
						<td><input  class="input-common middle"  type="text" value="{$partner_level_info.global_weight}" /></td>
						<td>{$partner_level_info.create_time|getTimeStampTurnTime}</td>
					</tr>					
				{/foreach}
				</tbody>
			</table>
		</div>
	</div>
	<div style="padding:13px;text-align:center;">
	<button class="btn-common btn-big" onclick="updateGlobalBonusPoolConfig();">提交</button>
	</div>
</div>
<script>
function updateGlobalBonusPoolConfig(){
	var trObj = $("#partner_global");
	var partner_level_string = "";
	$("#partner_global tr").each(function() {
		var level_id = $(this).data("level_id");
		var global_value = $(this).children().eq(1).children("input").val();
		var global_weight = $(this).children().eq(2).children("input").val();
		partner_level_string = partner_level_string + ";" + level_id + "," + global_value + "," + global_weight;
	});
	partner_level_string = partner_level_string.substring(1, partner_level_string.length );
	$.ajax({
		type:"post",
		url:"{:__URL('__URL__/nsfx/ADMIN_MODULE/distribution/updateglobalbonuspoolconfig')}",
		data:{
			'partner_level_string':partner_level_string
		},
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('__URL__/nsfx/ADMIN_MODULE/distribution/globalbonuspoolconfig')}");
			}else{
				showMessage('error', data["message"]);
			}	
		}
	});
}
/**
 * 开启全球分红
 */
function openGlobalEnable(is_open){
	$.ajax({
		type:"post",
		url:"{:__URL('__URL__/nsfx/ADMIN_MODULE/distribution/updatenfxshopconfigfield')}",
		data:{
			'fieldvalue':is_open,
			'fieldname':'is_global_enable'
		},
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('__URL__/nsfx/ADMIN_MODULE/distribution/globalbonuspoolconfig')}");
			}else{
				showMessage('error', data["message"]);
			}
		}
	});
}
</script>
{/block}